package ru.magicreader.client.model;

import java.util.Stack;

import com.google.gwt.core.client.JavaScriptObject;
import com.google.gwt.core.client.JsArray;

public class User extends JavaScriptObject {
	
	protected User() {}
	
	public final static native User fromJsonString(String json) /*-{
		return eval('(' + json + ')');
	}-*/;
	
	public final native String getLogin() /*-{ return this.login; }-*/;
	
	public final native String getLogoutUrl() /*-{ return this.logoutUrl; }-*/;

	public final native JsArray<Feed> getFeeds() /*-{ return this.feeds; }-*/;
	
	public final native Settings getSettings() /*-{ return this.settings; }-*/;
	
	public final void removeFeed(int index) {
		JsArray<Feed> feeds = getFeeds();
		Stack<Feed> tmpStack = new Stack<Feed>();
		for(int i = 0; i < index; i++) {
			tmpStack.push(feeds.shift());
		}
		feeds.shift();
		while(!tmpStack.empty()) {
			feeds.unshift(tmpStack.pop());
		}
	}
}
